/**
* 
* @brief Definition of CLockServerSettingItemList
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/

// INCLUDE FILES

// Class include
#include "LockServerSettingItemList.h"


// ================= MEMBER FUNCTIONS =======================

/**
* Constructor.	Takes a copy of the reference to aDifficultyLevel
* @param aDifficultyLevel the level of difficulty which will be set
*/	
CLockServerSettingItemList::CLockServerSettingItemList (TUint aTimeInterval,TUint aAutoStart,TUint aEnableNote)
: iTimeInterval (aTimeInterval),iAutoStart(aAutoStart),iEnableNote(aEnableNote)
	{
	}

/**
*	
* Called by framework when the view size is changed.  Resizes the
* setting list accordingly.
*
*/
void CLockServerSettingItemList::SizeChanged()
	{
	if (ListBox()) 
		{
		ListBox()->SetRect(Rect());
		}
	}


/**
*	
* Creates the actual setting items for the list, passing
* ownership of them to the calling class.  Each setting
* item has a piece of member data which it sets values in.
*/
CAknSettingItem* CLockServerSettingItemList::CreateSettingItemL(TInt aIdentifier)
	{
	CAknSettingItem* settingItem = NULL;
	
	switch (aIdentifier)
		{
		case ESettingsListAutoStartSettingItem:
			settingItem = new (ELeave) CAknBinaryPopupSettingItem(aIdentifier, iAutoStart);
			break;
		case ESettingsListTimeIntervalSettingItem:
			settingItem = new (ELeave) CAknSliderSettingItem(aIdentifier, iTimeInterval);
			break;
		case ESettingsListNoteSettingItem:
			settingItem = new (ELeave) CAknBinaryPopupSettingItem (aIdentifier, iEnableNote);
			break;

		}
	return settingItem; // passing ownership
	}

/**
* Causes the edit page for the currently selected setting
* item to be displayed
*/
void CLockServerSettingItemList::ChangeSelectedItemL()
	{
	EditItemL(ListBox()->CurrentItemIndex(), ETrue);
	}

/**
* Called by the framework whenever an item is selected. 
* Causes the edit page for the currently selected setting item to be displayed and stores
* any changes made.
*/
void CLockServerSettingItemList::EditItemL (TInt aIndex, TBool aCalledFromMenu)
	{
	CAknSettingItemList::EditItemL(aIndex, aCalledFromMenu);
	(*SettingItemArray())[aIndex]->StoreL();

	}

	TBool CLockServerSettingItemList::UpdateSettings(TUint &aTimeInterval,TUint &aAutoStart,TUint &aEnableNote)
	{
		TBool changed;
		if( iTimeInterval == aTimeInterval && iAutoStart == aAutoStart && iEnableNote == aEnableNote)
		{
			// no para changed
			changed = EFalse;
		}
		else
		{
			aTimeInterval = iTimeInterval;
			aAutoStart = iAutoStart;
			aEnableNote = iEnableNote;
			changed = ETrue;
		}

		return changed;
	}
